package com.example.httpprocessor;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.example.httpprocessor.bean.ResponceData;
import com.example.httpprocessor.http.HttpCallback;
import com.example.httpprocessor.http.HttpHelper;
import com.example.httpprocessor.http.IHttpProcessor;

import java.util.ArrayList;
import java.util.HashMap;

import dagger.hilt.android.AndroidEntryPoint;

@AndroidEntryPoint
public class MainActivity extends AppCompatActivity {

    IHttpProcessor iHttpProcessor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String url = "https://v.juhe.cn/historyWeather/citys";
        HashMap<String,Object>  parms = new HashMap<>();
        parms.put("province_id","2");
        parms.put("key","bb52107206585ab074f5e59a8c73875b");
        //               注意             HttpCallback<ResponceData> 泛型里面一定要传参数进去，不然在解析里面的时候会报异常
//        HttpHelper.obtain().post(url, parms, new HttpCallback<ResponceData>() {
//            @Override
//            public void getOnSuccess(ResponceData objResult) {
//
//                Log.e("请求数据返回来了",objResult.toString());
//
//            }
//
//            @Override
//            public void getOnFailure(String objResult) {
//
//            }
//        });


        ArrayList arrayList = new ArrayList();

       iHttpProcessor = ((MyApplication)getApplication()).getiHttpProcessor();
       //               注意             HttpCallback<ResponceData> 泛型里面一定要传参数进去，不然在解析里面的时候会报异常
       iHttpProcessor.post(url, parms, new HttpCallback<ResponceData>() {
           @Override
           public void getOnSuccess(ResponceData objResult) {
               Log.e("请求数据返回来了", "  注入数据来  " + objResult.toString());
           }

           @Override
           public void getOnFailure(String objResult) {

           }
       });
    }
}